package cn.liuhulu.entity;

import cn.liuhulu.tool.Tools;
import javafx.beans.property.SimpleStringProperty;

/**
 * 产品
 * 
 * @author liula
 *
 */

public class Product {

	private SimpleStringProperty name; // 名称
	private SimpleStringProperty spec; // 规格
	private SimpleStringProperty price; // 价格

	public Product(String name, String spec, String price) {
		super();
		this.name = new SimpleStringProperty(name);
		this.spec = new SimpleStringProperty(spec);
		if (Tools.isNumber(price) || Tools.isDecimal(price)) {
			// 格式化价格，只显示小数点后两位小数
			this.price = new SimpleStringProperty(Tools.formatFloat(Float.valueOf(price)));
		} else {
			this.price = new SimpleStringProperty("错误：" + price);
		}

	}

	public String getName() {
		return name.get();
	}

	public void setName(String name) {
		this.name = new SimpleStringProperty(name);
	}

	public String getSpec() {
		return spec.get();
	}

	public void setSpec(String spec) {
		this.spec = new SimpleStringProperty(spec);
	}

	public String getPrice() {
		return price.get();
	}

	public void setPrice(String price) {
		this.price = new SimpleStringProperty(price);
	}

	@Override
	public String toString() {
		return name.get() + "," + spec.get() + "," + price.get();
	}

}
